package com.bardsoftware.foronuvolo.server;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bardsoftware.foronuvolo.data.ForumUser;

public class LogoutServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
//        if (!req.getRequestURL().toString().startsWith(ForoNuvoloConstants.FORUM_DOMAIN)) {
//            return;
//        }
        //if (req.getSession().getAttribute("user_id") != null) {
            req.setAttribute("user_id", ForumUser.ANONYMOUS.getID());
            req.setAttribute("friendConnectID", ForoNuvoloConstants.FRIEND_CONNECT_SITE_ID);
            req.setAttribute("redirectUrl", ForoNuvoloConstants.FORUM_JSP_PATH);
            getServletContext().getRequestDispatcher(JspHelper.getJspName("logout.jsp")).forward(req, resp);
            req.getSession().setAttribute("user_id", null);
        //} else {
            //resp.sendRedirect("/");
        //}
    }

}
